package com.zw.controller;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.zw.dao.impl.ElasticSearchDaoImpl;
import com.zw.model.AlarmRecord;
import com.zw.service.JestService;
import io.searchbox.client.JestResult;
import io.searchbox.core.SearchResult;
import org.apache.lucene.search.WildcardQuery;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;

/**
 * Created by Zw on 2018/3/8.
 */
public class test {
    private static final String indexName = "myindex";
    private static final String typeName = "mytype";
    public static void main(String[] args) throws Exception {
              /*  JestService jestService = new JestService();

        JestResult jestResult = jestService.get(jestService.getJestClient(), indexName, typeName, "1");
        System.out.println(jestResult.getJsonString());
        QueryBuilder queryBuilder = QueryBuilders.matchQuery("name","许志平");
        SearchResult search = jestService.search(jestService.getJestClient(), indexName, typeN ame, queryBuilder.toString());
        List<SearchResult.Hit<AlarmRecord, Void>> hits = search.getHits(AlarmRecord.class);
        for (int i = 0; i < hits.size(); i++) {
            System.out.println(hits.get(i).source.toString());
        }*/
        ElasticSearchDaoImpl elasticSearchDao = new ElasticSearchDaoImpl();
        JsonObject js = elasticSearchDao.createSearch1("哈哈", typeName, AlarmRecord.class, new String[]{"name"});

        System.out.println(js);

    }
}
